<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">点击</button>
    <script>
        const btn= document.getElementById('btn')
        btn.addEventListener('click',()=>{
            const worker=new Worker('worker.js')//worker.js文件跑成一个单独的线程
            //向worker线程发送消息
            worker.postMessage('hello worker')
        })
    </script>
    
</body>
</html>